@import '../variables.css';

/**
* Default styling
*/

.button {
  composes: interactionStyles from "../sharedStyles/interactionStyles.css";
  padding: 0 var(--gutter-static);
  text-align: center;
  -webkit-appearance: none;
  cursor: pointer;
  color: var(--color-text);
  border-radius: 999px;
  transition: background-color 0.25s, color 0.25s, opacity 0.07s;
  background-color: transparent;
  border: transparent;
  margin: 0 0 var(--gutter);
  white-space: nowrap;
  line-height: var(--line-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  outline: 0;
  opacity: 1;
  font-weight: var(--text-weight-button);
  font-size: var(--font-size-medium);
  min-height: var(--control-min-size-desktop);

  &:visited {
    color: inherit;
  }

  &::before {
    border-radius: 999px;
  }

  &.block {
    display: flex;
  }

  & + .button {
    margin-left: 0.25rem;
  }

  &.fullWidth {
    width: 100%;
  }

  &.fieldControl {
    background-color: transparent;
    margin: 0;
    padding: 0;
  }

  & + .button.fullWidth,
  & + .button.fieldControl {
    margin-left: 0;
  }

  /**
  * Colors
  */

  /**
  * Button Style: Default
  */

  &.default {
    background-color: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);

    & :global .stripes__icon {
      fill: var(--primary);
    }
  }

  /**
   * Button style primary
   */

  &.primary {
    background-color: var(--primary);
    border: 1px solid var(--primary);
    color: #fff;

    &:hover {
      opacity: 0.9;
    }
  }

  /**
  * Button Style: Success
  */

  &.success {
    background-color: var(--success);
    border: 1px solid var(--success);
    color: #fff;
  }

  /**
  * Button Style: Warning
  */

  &.warning {
    background-color: var(--warn);
    border: 1px solid var(--warn);
    color: #fff;
  }

  /**
  * Button Style: Danger
  */

  &.danger {
    background-color: var(--danger);
    border: 1px solid var(--danger);
    color: #fff;
  }

  &.dropdownActive {
    &[aria-expanded="true"],
    &:focus {
      border: 1px solid var(--danger);
    }

    &:focus {
      outline: none;
    }
  }

  &.textAlignStart {
    text-align: left;
  }

  &.paneHeaderButton {
    background-color: transparent;
    border: 1px solid transparent;
    margin: 0;
    border-radius: 0;
    padding: 8px;

    &.tab {
      font-weight: bold;
      border-width: 0;
      border-bottom: 4px solid transparent;

      &:focus,
      &:hover {
        outline: none;
        border-bottom: 4px solid var(--bg-hover);
      }

      &.selected {
        font-weight: bold;
        border-width: 0;
        border-bottom: 4px solid var(--primary);

        &:focus {
          border-bottom-color: color(var(--primary) shade(8%));
        }
      }

      &:hover {
        background: transparent;
      }
    }
  }

  &.paneHeaderNewButton {
    margin-right: 0.5rem;
  }

  &.noRadius {
    border-radius: 0;
  }

  &.noLeftRadius {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  &.noRightRadius {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  &.lastBorderOnly {
    border-right-color: transparent !important;
  }

  &.link {
    background-color: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--primary);
    padding: 0.25em;
  }

  &.bottomMargin0,
  &.marginBottom0 {
    margin-bottom: 0;
  }

  &.paddingSide0 {
    padding-left: 0;
    padding-right: 0;
  }

  &[disabled] {
    background-color: #ccc;
    border-color: #ccc;
    color: var(--color-text-p2);
    transition: opacity ease-in-out 500ms;
    pointer-events: none;
  }

  &.mega {
    font-size: var(--font-size-large);
  }

  &.slim {
    padding: 0.125rem 0.5rem;
  }
}

[dir="rtl"] {
  & .button {
    & + .button {
      margin-left: 0;
      margin-right: 0.25rem;
    }

    & + .button.fullWidth,
    & + .button.fieldControl {
      margin-right: 0;
    }

    &.textAlignStart {
      text-align: right;
    }
  }
}

.inner {
  display: flex;
  align-items: center;
}

/**
 * Dropdown Item style
 */

/* No margin on dropdownItem's */
.button.dropdownItem {
  margin: 0;
}

.dropdownItem {
  composes: interactionStyles boxOffsetStartMedium boxOffsetEndMedium from "../sharedStyles/interactionStyles.css";
  padding: 0.125rem 0;
  background-color: transparent;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;

  &[disabled] {
    background-color: transparent;
    border: 0;
  }

  &:hover,
  &:focus {
    outline: none;
  }
}

/**
 * Alignment
 */

.align-start {
  justify-content: flex-start;
}

.align-center {
  justify-content: center;
}

.align-end {
  justify-content: flex-end;
}
